package com.snake.win.obj;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.snake.win.AI.SnakeAi;
import com.snake.win.utils.GameUtils;

import java.util.ArrayList;

import static java.lang.Math.abs;
import static java.lang.Math.signum;

public class HeadObj extends GameObj {
    public HeadObj(int x, int y) {
        super(x, y);
    }
    public HeadObj(Texture image, int x, int y) {
        super(image, x, y);
    }

    int i=0;


    @Override
    public void paintSelf(SpriteBatch g) {
        float delta = Gdx.graphics.getDeltaTime();
        float speed = 5.0f;
        if (abs((float) snake_x - sprite.getX()) < 0.01f && abs((float) snake_y - sprite.getY()) < 0.01f) {
            sprite.setPosition(snake_x, snake_y);
            moveOK = true;
        } else if (abs((float) snake_x - sprite.getX()) < 1.5f && abs((float) snake_y - sprite.getY()) < 1.5f) {
            sprite.translate(signum(snake_x - sprite.getX())*delta*speed, signum(snake_y - sprite.getY())*delta*speed);
            moveOK = false;
        } else
        {
            sprite.setPosition(snake_x, snake_y);
            moveOK = true;
        }
        super.paintSelf(g);
    }


}
